home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / sos3-2.lha / src / agg / Aggregate_scp.c < prev    next >
C/C++ Source or Header  |  1992-01-23  |  3KB  |  101 lines

  1. #line 1 "/fzi/prost/stone/SOS3-2/src/agg/Aggregate.c"
  2. /* --------------------------------------------------------------------------
  3.  * Copyright 1992 by Forschungszentrum Informatik (FZI)
  4.  *
  5.  * You can use and distribute this software under the terms of the licence
  6.  * you should have received along with this program.
  7.  * If not or if you want additional information, write to
  8.  * Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
  9.  * D-7500 Karlsruhe 1, Germany.
  10.  * --------------------------------------------------------------------------
  11.  */
  12. // **************************************************************************
  13. // Module Aggregate                 30/08/89           Bernhard Schiefer (bs)
  14. //
  15. // **************************************************************************
  16. // implements methods of classes: sos_Aggregate, sos_Cursor
  17. // **************************************************************************
  18.  
  19. #include "sys.h"
  20. #include "agg_err.h"
  21. #include "trc_agg.h"
  22.  
  23. #include "agg_sos.h"
  24.  
  25. // **************************************************************************
  26. sos_Bool agg_same_entity (sos_Object o1, sos_Object o2,
  27.                   sos_Bool based_on_equal, sos_Eq_kind eq_kind)
  28. // **************************************************************************
  29. {  if (based_on_equal)
  30.       return o1.equal(o2, eq_kind);
  31.    else
  32.       return o1.identical(o2);
  33. }
  34.  
  35.  
  36. // **************************************************************************
  37. sos_Bool _sos_Aggregate::is_empty (sos_Typed_id &_tpid)
  38. // **************************************************************************
  39. {
  40.    T_PROC ("sos_Aggregate::is_empty");
  41.    TT (agg_H, T_ENTER);
  42.  
  43.    sos_Bool result = (sos_Bool)(sos_Aggregate::make(_tpid,this).card() == 0);
  44.  
  45.    TT (agg_H, T_LEAVE; TI (result));
  46.    return result;
  47. } // ** is_empty **
  48.  
  49. // **************************************************************************
  50. void _sos_Aggregate::clear (sos_Typed_id &_tpid)
  51. // **************************************************************************
  52. {
  53.    T_PROC ("Aggregate::clear");
  54.    TT (agg_H, T_ENTER);
  55.  
  56.    sos_Cursor c = sos_Aggregate::make(_tpid,this).open_cursor ();
  57.  
  58.    for ( ;
  59.      sos_Aggregate::make(_tpid,this).is_valid (c);
  60.      sos_Aggregate::make(_tpid,this).remove_at (c) ) ; // no body
  61.  
  62.    sos_Aggregate::make(_tpid,this).close_cursor (c);
  63.  
  64.    TT (agg_H, T_LEAVE);
  65. } // ** clear **
  66.  
  67.  
  68. // *******************************   sos_Cursor   ***************************
  69.  
  70. // **************************************************************************
  71. void _sos_Cursor::local_initialize (sos_Cursor c)
  72. // **************************************************************************
  73. {
  74.    T_PROC ("sos_Cursor::local_initialize");
  75.    TT (agg_H, T_ENTER);
  76.  
  77.    c.set_current (sos_Node::make (NO_OBJECT));
  78.  
  79.    TT (agg_H, T_LEAVE);
  80. } // ** local_initialize **
  81.  
  82.  
  83. // **************************************************************************
  84. sos_Bool _sos_Cursor::defined_for (sos_Typed_id &_tpid,sos_Aggregate agg)
  85. // **************************************************************************
  86. {
  87.    T_PROC ("sos_Cursor::defined_for");
  88.    TT (agg_H, T_ENTER);
  89.  
  90. #ifdef ATT
  91.    sos_Bool result = (sos_Bool)(agg.operator==(sos_Cursor::make(_tpid,this).get_domain()));
  92. #else
  93.    sos_Bool result = (sos_Bool)(agg == sos_Cursor::make(_tpid,this).get_domain());
  94. #endif
  95.  
  96.    TT (agg_H, T_LEAVE);
  97.  
  98.    return result;
  99.  
  100. } // ** defined_for **
  101.